package com.one.consumer.reserve.ui.activity;

import android.widget.RadioGroup;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.one.common.config.RouterPath;
import com.one.common.view.base.IListView;
import com.one.common.view.widget.MyTitleBar;
import com.one.consumer.BaseListActivityC;
import com.one.consumer.R;
import com.one.common.common.order.extra.ReserveExtra;
import com.one.consumer.reserve.model.item.CustomItem;
import com.one.consumer.reserve.model.item.ReserveItem;
import com.one.consumer.reserve.presenter.ReserveCenterPresenter;
import com.one.consumer.reserve.ui.binder.CustomBinder;
import com.one.consumer.reserve.ui.binder.ReserveBinder;

/**
 * Author: zhulunjun
 * Time  : 2018/10/25 10:55
 * email : zhulunjun@qq.com
 * Describe : 预约中心
 **/
@Route(path = RouterPath.RESERVE_CENTER)
public class ReserveCenterActivity extends BaseListActivityC<ReserveCenterPresenter> implements IListView,
        RadioGroup.OnCheckedChangeListener ,CustomBinder.RefreshListener,ReserveBinder.RefreshListener {
    /**
     * 区分是装修还是设计预约
     */
    private String type = ReserveExtra.STYLE_DE;
    private RadioGroup rgReserve;
    @Override
    protected void initPresenter() {
        mPresenter = new ReserveCenterPresenter(this,this);
    }

    @Override
    public void registerDate() {
        register(ReserveItem.class, new ReserveBinder(this));
        register(CustomItem.class, new CustomBinder(this));
    }

    @Override
    public void loadData() {
        mPresenter.getReserveList(type);
    }

    @Override
    public void initData() {
        super.initData();
        loadData();
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("预约中心");
    }

    @Override
    public void initView() {
        super.initView();
        addTopView(R.layout.layout_reserve_center_top);
        rgReserve = successView.findViewById(R.id.rg_reserve);
        rgReserve.setOnCheckedChangeListener(this);
    }

    @Override
    public boolean onEmpty() {
        return true;
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.rb_de:
                type = ReserveExtra.STYLE_DE;
                break;
            case R.id.rb_dy:
                type = ReserveExtra.STYLE_DY;
                break;
            case R.id.rb_cu:
                type = ReserveExtra.STYLE_CU;
                break;
            default:
                break;
        }

        doRefresh();
    }

    @Override
    public void onRefresh() {
        doRefresh();
    }
}
